package com.gitee.wsl.doc.prosemirror.state.bookmark

import com.gitee.wsl.doc.prosemirror.model.node.Node
import com.gitee.wsl.doc.prosemirror.state.selection.Selection
import com.gitee.wsl.doc.prosemirror.transform.map.Mappable

// A lightweight, document-independent representation of a selection. You can define a custom
// bookmark type for a custom selection class to make the history handle it well.
interface SelectionBookmark {
    // Map the bookmark through a set of changes.
    fun map(mapping: Mappable): SelectionBookmark

    // Resolve the bookmark to a real selection again. This may need to do some error checking and
    // may fall back to a default (usually [`TextSelection.between`](#state.TextSelection^between))
    // if mapping made the bookmark invalid.
    fun resolve(doc: Node): Selection
}